import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Picker, Swiper, SwiperItem } from '@tarojs/components'
import {AtList, AtListItem, AtIcon} from 'taro-ui'
import './selectPatient.scss'
import reactMixin  from 'react-mixin'
import myJs from './selectPatientJs.js'
import app from '../../../main';

export default class SelectPatient extends Component {
    constructor () { 
        super(...arguments); 
        this.state = this.getData(); 
    }
    config = {
        navigationBarTitleText: '选择患者'
    }

    init() {
        this.setState({
            doctor_id: this.$router.params.doctor_id,
        });
        
        this.allPatients();
    }

    render () {
        return (
            <View className='selectPatient'>
                 <AtList hasBorder={false}>
                     {
                         this.state.patients.map((item)=>{
                            return (
                                <AtListItem onClick={this.gotoEditCase.bind(this, item.id)} 
                                hasBorder={false} 
                                title={item.name} 
                                note={item.gender} arrow='right' thumb={app.getPath(item.head_image)}/>
                            )
                         })
                     }
                </AtList>

                {
                    this.state.patients.length == 0 ? (
                        <View className='tip' hasBorder={false} >
                            <AtIcon value='alert-circle' size='20' color='#666'></AtIcon>
                            <Text>没有患者可选</Text>
                        </View>
                        ): (<View></View>)
                }
            </View>
        );
    }
}

reactMixin.onClass(SelectPatient, myJs);
